<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/template/common/header.jsp"%>
<script type="text/javascript">
	var product = {
		uploadSuccess : function(file, data, response) {
			if (!response) {
				return;
			}
			var $this = $(this);
			data = eval("(" + data + ")");
			$this
					.each(function(i) {
						var $wrapper = $this[i].wrapper;
						$wrapper.siblings("input[name='product.image']").val(
								data.url);
						var fileQue = $wrapper.siblings("div.thumbImg");
						fileQue.empty();
						var img = $("<img src='" + resourceRootUrl + data.url
						+ "' height='150px'/>");
						fileQue.append(img);
					});
		}
	}
</script>
<div class="pageContent">
	<form method="post" action="${base }/product!doEdit.action"
		class="pageForm required-validate"
		onsubmit="return validateCallback(this, navTabAjaxDone)">
		<div class="pageFormContent" layoutH="55">
			<input type="hidden" name="product.id" value="${product.id}">
			<dl class="nowrap">
				<dt>商品名称：</dt>
				<dd>
					<input type="text" name="product.title" size="30" minlength="4"
						maxlength="100" class="required" value="${product.title}" />
				</dd>
			</dl>
			<dl class="nowrap">
				<dt>URL：</dt>
				<dd>
					<input type="text" name="product.targetUrl" class="required url"
						size="40" value="${product.targetUrl}" />
				</dd>
			</dl>
			<dl class="nowrap">
				<dt>标价：</dt>
				<dd>
					$<input type="text" name="product.price"
						class="{required:true,double:[3,6]}" value="${product.price}" />
				</dd>
			</dl>
			<dl class="nowrap">
				<dt>来源：</dt>
				<dd>
					<select name="product.source">
						<option value="amazon"
							<c:if test="${product.source=='amazon' }">selected='selected'</c:if>>amazon</option>
						<option value="eBay"
							<c:if test="${product.source=='eBay' }">selected='selected'</c:if>>eBay</option>
					</select>
				</dd>
			</dl>
			<dl class="nowrap">
				<dt>描述：</dt>
				<dd>
					<textarea rows="10" cols="80" name="product.summary"
						class="required">${product.summary }</textarea>
				</dd>
			</dl>
			<dl class="nowrap">
				<dt>图片：</dt>
				<dd>
					<input id="${rel }FileProduct" target="uploadify" type="file"
						name="filedata"
						uploadifyOpts='{"onUploadSuccess":product.uploadSuccess}' /> <input
						type="hidden" name="product.image" class="required"
						value="${product.image }">
					<div class="thumbImg">
						<c:if test="${product.image ne null }">
							<img src="${resourceRootUrl	}${product.image}" />
						</c:if>
					</div>
				</dd>
			</dl>
		</div>
		<div class="formBar">
			<ul>
				<li><div class="buttonActive">
						<div class="buttonContent">
							<button type="submit">提交</button>
						</div>
					</div></li>
				<li><div class="button">
						<div class="buttonContent">
							<button type="button" class="close">取消</button>
						</div>
					</div></li>
			</ul>
		</div>
	</form>

</div>
